﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XZL.GM.Dal;

namespace XZL.GM.Bll
{
 public class CommentInfo
    {

        /// <summary>
        /// 获取评价列表
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="status"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
     public static List<Proc_CommentInfo_SelectListResult> GetCommentList(int courseID,DateTime start,DateTime end,int pageIndex, int pageSize, ref int? pageCount)
     {
          Request_GmDataContext hk = new Request_GmDataContext();

         //截取字符串   注：评论和回复分别截取50个字符

     List<Proc_CommentInfo_SelectListResult> ls = hk.Proc_CommentInfo_SelectList(courseID,start,end, pageIndex, pageSize, ref pageCount).ToList();
       
         foreach(var obj in ls)
         {
             if (obj.CommentContent!=null && obj.CommentContent.Length > 50)
             {
              obj.CommentContent = obj.CommentContent.Substring(0, 50)+"......";

              if (obj.ReplyContent!=null && obj.ReplyContent.Length > 50)
              {
                  obj.ReplyContent = obj.ReplyContent.Substring(0, 50) + "......";
              }
           }
            
         }
         return ls;
     }

     /// <summary>
     /// 获取评价信息
     /// </summary>
     /// <param name="msgID"></param>
     /// <returns></returns>
     public static Proc_CommentInfo_SelectInfoResult GetCommentInfo(string commentID)
     {
     Request_GmDataContext hk = new Request_GmDataContext();
     return hk.Proc_CommentInfo_SelectInfo(commentID).FirstOrDefault();
     }

     /// <summary>
     /// 回复用户留言
     /// </summary>
     /// <param name="commentID"></param>
     /// <param name="reply"></param>
     /// <returns></returns>
     public static bool ReplyMsg(string commentID, string replyContent)
     {
         Request_GmDataContext hk = new Request_GmDataContext();
         hk.Proc_CommentReply_Info(commentID,replyContent);
         return true;
     }

        /// <summary>
        /// 修改审批状态
        /// </summary>
        /// <param name="commentID"></param>
        /// <param name="reply"></param>
        /// <returns></returns>
     public static bool ChangeStatus(string commentID, int status)
     {
         Request_GmDataContext hk = new Request_GmDataContext();
          hk.Proc_CommentInfo_UpdateStatus(commentID, status);
          return true;
     }

    }
}
